<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<h1 style="text-align: center"><bean:message key="message.title"/></h1>
<html:errors/>
<c:choose>
    <c:when test="${empty mensajes}">
        <p style="text-align: center"><bean:message key="list.nomessages"/></p>
    </c:when>
    <c:otherwise>
        <br/><table class="table table-striped">
            <tr>
                <th><bean:message key="list.sender"/></th>
                <th><bean:message key="list.subject"/></th>
                <th><bean:message key="list.date"/></th>
            </tr>
            <logic:present name="mensajes">
                <logic:iterate id="lista" name="mensajes">
                    <tr>
                        <c:choose>
                            <c:when test="${lista.estados.idestado == 10}">
                                <td>
                                    <span class="textbox"><bean:write name="lista" property="usuariosByIdremitente.alias" /></span>
                                </td>
                                <td>
                                    <span class="textbox"><bean:write name="lista" property="titulo"/></span>
                                </td>
                                <td>
                                    <span class="textbox"><bean:write name="lista" property="fecha" format="hh:mm dd/MM/yyyy"/></span>
                                </td>
                            </c:when>
                            <c:otherwise>
                                <td>
                                    <span class="textbox"><bean:write name="lista" property="usuariosByIdremitente.alias"/></span>
                                </td>
                                <td>
                                    <span class="textbox"><bean:write name="lista" property="titulo"/></span>
                                </td>
                                <td>
                                    <span class="textbox"><bean:write name="lista" property="fecha" format="hh:mm dd/MM/yyyy"/></span>
                                </td>
                            </c:otherwise>
                        </c:choose>
                        <td>
                            <html:link action="/readMessage?idmensaje=${lista.idmensaje}" styleClass="azul"><bean:message key="list.read"/></html:link> 
                            </td><td><html:link action="/deleteMessage?idmensaje=${lista.idmensaje}" styleClass="rojo"><bean:message key="list.delete"/></html:link>
                            </td>
                        </tr>
                </logic:iterate>
            </logic:present>
        </table>
    </c:otherwise>              
</c:choose>
